﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace BaoJian.Control.local
{
    /// <summary>
    /// 地方版底部的三个栏目
    /// </summary>
    public partial class ImageDocListEx : System.Web.UI.UserControl
    {
        public string Region;
        //public bool ShowImage = true;
        public int ImageTitleLength;
        public int DocTitleLength;
        public int Count;
        public string ColumnID;
        //public string ColumnName;

        //public int ImageHeight;
        //public int ImageWidth;     

        private string sql1 = " SELECT TOP 1  sid,oid,pid,left(title,{0}) as Title,summary,ctime,FirstSmallImage  FROM doc WHERE Region='{1}'AND PID='{2}' AND Recommand=1 and publish=1 ORDER BY CTime DESC ";
        private string sql2 = " SELECT TOP {0} sid,oid,pid,left(title,{1}) as Title,summary,ctime FROM doc WHERE Region='{2}'AND PID='{3}' AND Recommand != 1 and publish=1 ORDER BY CTime DESC";
        public DataSet ds;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {                  
                string sql = string.Format(sql1, ImageTitleLength, Region, ColumnID) + string.Format(sql2, Count, DocTitleLength, Region, ColumnID);
                ds = Maticsoft.DBUtility.DbHelperSQL.Query(sql);
                Repeater1.DataSource = ds.Tables[1];
                Repeater1.DataBind(); 
            }
        }
    }
}